﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPNETPerformance.App_BusinessLogic.BasePages;
using ASPNETPerformance.App_BusinessLogic.Helpers;
using ASPNETPerformance.App_BusinessLogic.Image;
using ASPNETPerformance.App_BusinessLogic.Utils;

namespace ASPNETPerformance._03_Image {
    public partial class Base64String : BasePage {
        protected void Page_Load( object sender, EventArgs e ) {
            if ( !this.Page.IsPostBack )
            {
                BindData();
            }
        }

        private void BindData()
        {
            string imgUrl = "_assets/img/feed-icon-28x28.png";
            if ( CommonHelper.GetCookieBool( "IsImageBase64String" ) )
            {
                imgUrl = ImageManager.GetBase64Image( Server.MapPath( "~/" + imgUrl ) );
            }
            else
            {
                imgUrl = CommonHelper.GetDemosLocation() + imgUrl;
            }

            this.image1.ImageUrl = imgUrl;
        }
    }
}